package action.plan;

import presentation.extendmodel.PlanDetailModel;
import service.PlanService;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class SubmittedPlanDetailAction extends ActionSupport {

    private static final long serialVersionUID = 1L;

    private PlanService planService;

    private String planId;

    private PlanDetailModel planDetail;

    private String optRet;

    public String submittedPlanDetailPre() throws Exception {
        return Action.SUCCESS;
    }

    public String getDetailData() throws Exception {

        planDetail = planService.getPlanDetail(planId);

        return Action.SUCCESS;
    }

    public String passSubmittedPlan() throws Exception {

        int ret = planService.passSubmittedPlan(planId);
        if (ret != 0) {
            optRet = "success";
        } else {
            optRet = "failed";
        }
        return Action.SUCCESS;
    }

    public String rejectSubmittedPlan() throws Exception {

        int ret = planService.rejectSubmittedPlan(planId);
        if (ret != 0) {
            optRet = "success";
        } else {
            optRet = "failed";
        }
        return Action.SUCCESS;
    }

    public String deleteSubmittedPlan() throws Exception {

        int ret = planService.deleteSubmittedPlan(planId);
        if (ret != 0) {
            optRet = "success";
        } else {
            optRet = "failed";
        }
        return Action.SUCCESS;
    }

    public void setPlanService(PlanService planService) {
        this.planService = planService;
    }

    public String getPlanId() {
        return planId;
    }

    public void setPlanId(String planId) {
        this.planId = planId;
    }

    public PlanDetailModel getPlanDetail() {
        return planDetail;
    }

    public void setPlanDetail(PlanDetailModel planDetail) {
        this.planDetail = planDetail;
    }

    public String getOptRet() {
        return optRet;
    }

    public void setOptRet(String optRet) {
        this.optRet = optRet;
    }

}
